
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>particle_size_models &#8212; Texas A&amp;M Oil spill / Outfall Calculator 2.1.0 documentation</title>
    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
   
  <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <h1>Source code for particle_size_models</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Particle Size Models</span>
<span class="sd">====================</span>

<span class="sd">Compute particle size distributions for jets of oil and gas</span>

<span class="sd">This module provides an interface to available empirical models for bubble</span>
<span class="sd">and droplet size distributions for jet releases.  The empirical model</span>
<span class="sd">functions are in `psf.py`; this module provides an object-oriented interface</span>
<span class="sd">to these functions.  Gas bubble size distributions can be created from:</span>

<span class="sd">* Li et al. (2017)</span>
<span class="sd">* Wang et al. (2018)</span>

<span class="sd">Oil droplet size distributions can be created from:</span>

<span class="sd">* Johansen et al. (2013)</span>
<span class="sd">* Li et al. (2017)</span>

<span class="sd">All models support log-normal and Rosin-Rammler distributions.</span>

<span class="sd">Notes</span>
<span class="sd">-----</span>

<span class="sd">The particle size computational algorithms are contained in the module</span>

<span class="sd">    `psf.py` - Particle Size Fuctions</span>

<span class="sd">This module is a function library used by the objects in this module.  In</span>
<span class="sd">general, the `psf` module can be replace by any module having the same</span>
<span class="sd">application programming interface, whether programmed in Python, or another</span>
<span class="sd">language and wrapped in Python.</span>

<span class="sd">See Also</span>
<span class="sd">--------</span>

<span class="sd">To date, only simple, analytical equations have been implemented in the</span>
<span class="sd">partice size functions. More complex, physics-based models using a population</span>
<span class="sd">dynamic approach are also often used. These may be added in the future. See,</span>
<span class="sd">for example:</span>

<span class="sd">    Zhao, L., Boufadel, M. C., Socolofsky, S. A., Adams, E., King, T., and</span>
<span class="sd">    Lee, K. (2014). &quot;Evolution of droplets in subsea oil and gas blowouts:</span>
<span class="sd">    Development and validation of the numerical model VDROP-J.&quot; Mar Pollut</span>
<span class="sd">    Bull, 83(1), 58-69.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="c1"># S. Socolofsky, March 2020, Texas A&amp;M University, &lt;socolofs@tamu.edu&gt;</span>

<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="p">(</span><span class="n">absolute_import</span><span class="p">,</span> <span class="n">division</span><span class="p">,</span> <span class="n">print_function</span><span class="p">)</span>

<span class="kn">from</span> <span class="nn">tamoc</span> <span class="kn">import</span> <span class="n">psf</span><span class="p">,</span> <span class="n">seawater</span><span class="p">,</span> <span class="n">dbm</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="c1"># import matplotlib.pyplot as plt</span>

<div class="viewcode-block" id="ModelBase"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.ModelBase.html#particle_size_models.ModelBase">[docs]</a><span class="k">class</span> <span class="nc">ModelBase</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Master class object for interfacing with functions in the `psf` module</span>

<span class="sd">    This base model class contains the attributes necessary to directly call</span>
<span class="sd">    the functions in the `psf` module.  This class is also initialized with</span>
<span class="sd">    these fluid properties; hence, this class can be used independently of</span>
<span class="sd">    ``TAMOC`` or the discrete particle module (`dbm`) in TAMOC.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    rho_gas : float</span>
<span class="sd">        Density of the gas phase released from the jet (kg/m^3)</span>
<span class="sd">    mu_gas : float</span>
<span class="sd">        Dynamic viscosity of the gas phase released from the jet (Pa s)</span>
<span class="sd">    sigma_gas : float</span>
<span class="sd">        Interfacial tension between the gas phase released from the jet and</span>
<span class="sd">        the continuous-phase receiving fluid (N/m)</span>
<span class="sd">    rho_oil : float</span>
<span class="sd">        Density of the liquid phase released from the jet (kg/m^3)</span>
<span class="sd">    mu_oil : float</span>
<span class="sd">        Dynamic viscosity of the liquid phase released from the jet (Pa s)</span>
<span class="sd">    sigma_oil : float</span>
<span class="sd">        Interfacial tension between the liquid phase released from the jet</span>
<span class="sd">        and the continuous-phase receiving fluid (N/m)</span>
<span class="sd">    rho : float</span>
<span class="sd">        Density of the continuous-phase receiving fluid (kg/m^3)</span>
<span class="sd">    mu : float</span>
<span class="sd">        Dynamic viscosity of the continuous-phase receiving fluid (Pa s)</span>

<span class="sd">    Attributes</span>
<span class="sd">    ----------</span>
<span class="sd">    rho_gas : float</span>
<span class="sd">        Density of the gas phase released from the jet (kg/m^3)</span>
<span class="sd">    mu_gas : float</span>
<span class="sd">        Dynamic viscosity of the gas phase released from the jet (Pa s)</span>
<span class="sd">    sigma_gas : float</span>
<span class="sd">        Interfacial tension between the gas phase released from the jet and</span>
<span class="sd">        the continuous-phase receiving fluid (N/m)</span>
<span class="sd">    rho_oil : float</span>
<span class="sd">        Density of the liquid phase released from the jet (kg/m^3)</span>
<span class="sd">    mu_oil : float</span>
<span class="sd">        Dynamic viscosity of the liquid phase released from the jet (Pa s)</span>
<span class="sd">    sigma_oil : float</span>
<span class="sd">        Interfacial tension between the liquid phase released from the jet</span>
<span class="sd">        and the continuous-phase receiving fluid (N/m)</span>
<span class="sd">    rho : float</span>
<span class="sd">        Density of the continuous-phase receiving fluid (kg/m^3)</span>
<span class="sd">    mu : float</span>
<span class="sd">        Dynamic viscosity of the continuous-phase receiving fluid (Pa s)</span>
<span class="sd">    sim_stored : bool</span>
<span class="sd">        Flag indicating whether or not the particle size distribution</span>
<span class="sd">        algorithm has been calculated since the last property update.</span>
<span class="sd">    distribution_stored : bool</span>
<span class="sd">        Flag indicating whether or not the particle size distribution has</span>
<span class="sd">        been computed and stored since the last property update.</span>
<span class="sd">    d0 : float</span>
<span class="sd">        Equivalent circular diameter of the release orifice (m)</span>
<span class="sd">    m_gas : float</span>
<span class="sd">        Mass flow rate of gas released from the jet (kg/s)</span>
<span class="sd">    m_oil : float</span>
<span class="sd">        Mass flow rate of liquid released from the jet (kg/s)</span>
<span class="sd">    model_gas : str</span>
<span class="sd">        Name of the model used for computing the gas bubble size</span>
<span class="sd">        distribution.  Choices are &#39;wang_etal&#39; or &#39;li_etal&#39;:.</span>
<span class="sd">    model_oil : str</span>
<span class="sd">        Name of the model used for computing the oil droplet size</span>
<span class="sd">        distribution.  Choices are &#39;sintef&#39; or &#39;li_etal&#39;.</span>
<span class="sd">    pdf_gas : str</span>
<span class="sd">        Probability density function to use for the gas bubble size</span>
<span class="sd">        distribution.  Choices are &#39;lognormal&#39; or &#39;rosin-rammler&#39;.</span>
<span class="sd">    pdf_oil : str</span>
<span class="sd">        Probability density function to use for the oil droplet size</span>
<span class="sd">        distribution.  Choices are &#39;lognormal&#39; or &#39;rosin-rammler&#39;.</span>
<span class="sd">    d50_gas : float</span>
<span class="sd">        Median equivalent spherical diameter of gas bubbles (m)</span>
<span class="sd">    de_max_gas : float</span>
<span class="sd">        Maximum stable bubble size (equivalent spherical diameter) of gas</span>
<span class="sd">        bubbles (m).</span>
<span class="sd">    de_gas : ndarray</span>
<span class="sd">        Array of equivalent spherical diameters of bubbles in the bubble</span>
<span class="sd">        size distribution (log-distributed, m)</span>
<span class="sd">    vf_gas : ndarray</span>
<span class="sd">        Array of volume fractions of gas corresponding to each bubble size</span>
<span class="sd">        in the  `de_gas` bubble size distribution (--)</span>
<span class="sd">    d50_oil : float</span>
<span class="sd">        Median equivalent spherical diameter of oil droplets (m)</span>
<span class="sd">    de_max_oil : float</span>
<span class="sd">        Maximum stable droplet size (equivalent spherical diameter) of oil</span>
<span class="sd">        droplets (m).</span>
<span class="sd">    de_oil : ndarray</span>
<span class="sd">        Array of equivalent spherical diameters of droplets in the droplet</span>
<span class="sd">        size distribution (log-distributed, m)</span>
<span class="sd">    vf_oil : ndarray</span>
<span class="sd">        Array of volume fractions of oil corresponding to each droplet size</span>
<span class="sd">        in the  `de_oil` droplet size distribution (--)</span>

<span class="sd">    See Also</span>
<span class="sd">    --------</span>
<span class="sd">    PureJet, Model</span>

<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    This class should only be used is the chemical properties are not going</span>
<span class="sd">    to be computed using the ``TAMOC`` `dbm`.  If the `dbm` is going to be</span>
<span class="sd">    used, then the regular `Model` class should be used instead.</span>

<span class="sd">    &quot;&quot;&quot;</span>
<div class="viewcode-block" id="ModelBase.__init__"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.ModelBase.html#particle_size_models.ModelBase.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">rho_gas</span><span class="p">,</span> <span class="n">mu_gas</span><span class="p">,</span> <span class="n">sigma_gas</span><span class="p">,</span> <span class="n">rho_oil</span><span class="p">,</span> <span class="n">mu_oil</span><span class="p">,</span>
                 <span class="n">sigma_oil</span><span class="p">,</span> <span class="n">rho</span><span class="p">,</span> <span class="n">mu</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">ModelBase</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>

        <span class="c1"># Record the release properties</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">update_properties</span><span class="p">(</span><span class="n">rho_gas</span><span class="p">,</span> <span class="n">mu_gas</span><span class="p">,</span> <span class="n">sigma_gas</span><span class="p">,</span> <span class="n">rho_oil</span><span class="p">,</span> <span class="n">mu_oil</span><span class="p">,</span>
                               <span class="n">sigma_oil</span><span class="p">,</span> <span class="n">rho</span><span class="p">,</span> <span class="n">mu</span><span class="p">)</span></div>

<div class="viewcode-block" id="ModelBase.update_properties"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.ModelBase.update_properties.html#particle_size_models.ModelBase.update_properties">[docs]</a>    <span class="k">def</span> <span class="nf">update_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">rho_gas</span><span class="p">,</span> <span class="n">mu_gas</span><span class="p">,</span> <span class="n">sigma_gas</span><span class="p">,</span> <span class="n">rho_oil</span><span class="p">,</span> <span class="n">mu_oil</span><span class="p">,</span>
                          <span class="n">sigma_oil</span><span class="p">,</span> <span class="n">rho</span><span class="p">,</span> <span class="n">mu</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Set the thermodynamic properties of the released and receiving fluids</span>

<span class="sd">        Store the density, viscosity, and interfacial tension of the fluids</span>
<span class="sd">        involved in a jet breakup scenario.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        rho_gas : float</span>
<span class="sd">            Density of the gas phase released from the jet (kg/m^3)</span>
<span class="sd">        mu_gas : float</span>
<span class="sd">            Dynamic viscosity of the gas phase released from the jet (Pa s)</span>
<span class="sd">        sigma_gas : float</span>
<span class="sd">            Interfacial tension between the gas phase released from the jet</span>
<span class="sd">            and the continuous-phase receiving fluid (N/m)</span>
<span class="sd">        rho_oil : float</span>
<span class="sd">            Density of the liquid phase released from the jet (kg/m^3)</span>
<span class="sd">        mu_oil : float</span>
<span class="sd">            Dynamic viscosity of the liquid phase released from the jet (Pa s)</span>
<span class="sd">        sigma_oil : float</span>
<span class="sd">            Interfacial tension between the liquid phase released from the</span>
<span class="sd">            jet and the continuous-phase receiving fluid (N/m)</span>
<span class="sd">        rho : float</span>
<span class="sd">            Density of the continuous-phase receiving fluid (kg/m^3)</span>
<span class="sd">        mu : float</span>
<span class="sd">            Dynamic viscosity of the continuous-phase receiving fluid (Pa s)</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Set the flags initially to False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">distribution_stored</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="c1"># Record the properties</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">rho_gas</span> <span class="o">=</span> <span class="n">rho_gas</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mu_gas</span> <span class="o">=</span> <span class="n">mu_gas</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sigma_gas</span> <span class="o">=</span> <span class="n">sigma_gas</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">rho_oil</span> <span class="o">=</span> <span class="n">rho_oil</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mu_oil</span> <span class="o">=</span> <span class="n">mu_oil</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sigma_oil</span> <span class="o">=</span> <span class="n">sigma_oil</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">rho</span> <span class="o">=</span> <span class="n">rho</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mu</span> <span class="o">=</span> <span class="n">mu</span></div>

<div class="viewcode-block" id="ModelBase.simulate"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.ModelBase.simulate.html#particle_size_models.ModelBase.simulate">[docs]</a>    <span class="k">def</span> <span class="nf">simulate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">d0</span><span class="p">,</span> <span class="n">m_gas</span><span class="p">,</span> <span class="n">m_oil</span><span class="p">,</span> <span class="n">model_gas</span><span class="o">=</span><span class="s1">&#39;wang_etal&#39;</span><span class="p">,</span>
                 <span class="n">model_oil</span><span class="o">=</span><span class="s1">&#39;sintef&#39;</span><span class="p">,</span> <span class="n">pdf_gas</span><span class="o">=</span><span class="s1">&#39;lognormal&#39;</span><span class="p">,</span>
                 <span class="n">pdf_oil</span><span class="o">=</span><span class="s1">&#39;rosin-rammler&#39;</span><span class="p">,</span> <span class="n">Pa</span><span class="o">=</span><span class="mf">4.e6</span><span class="p">,</span> <span class="n">Ta</span><span class="o">=</span><span class="mf">288.15</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Compute the parameters of the particle size distribution</span>

<span class="sd">        Computes the median bubble and droplet sizes and the spread</span>
<span class="sd">        of the selected size distributions.  Models for gas bubble median</span>
<span class="sd">        size are `wang_etal` or `li_etal`; models for oil droplet median</span>
<span class="sd">        size are `sintef` or `li_etal`.  Size distributions are either</span>
<span class="sd">        `lognormal` or `rosin-rammler`.  No matter what model is selected,</span>
<span class="sd">        the `d_95`-rule is used when the predicted size distribution would</span>
<span class="sd">        exceed the maximum stable bubble or droplet size.  Under that rule,</span>
<span class="sd">        the 95-percentile of the volume size distribution is set to the</span>
<span class="sd">        maximum stable size, and the median size is adjusted downward.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        d0 : float</span>
<span class="sd">            Equivalent circular diameter of the release orifice (m)</span>
<span class="sd">        m_gas : float</span>
<span class="sd">            Mass flow rate of gas released from the jet (kg/s)</span>
<span class="sd">        m_oil : float</span>
<span class="sd">            Mass flow rate of liquid released from the jet (kg/s)</span>
<span class="sd">        model_gas : str, default=&#39;wang_etal&#39;</span>
<span class="sd">            Name of the model used for computing the gas bubble size</span>
<span class="sd">            distribution.  Choices are &#39;wang_etal&#39; or &#39;li_etal&#39;:.</span>
<span class="sd">        model_oil : str, default=&#39;sintef&#39;</span>
<span class="sd">            Name of the model used for computing the oil droplet size</span>
<span class="sd">            distribution.  Choices are &#39;sintef&#39; or &#39;li_etal&#39;.</span>
<span class="sd">        pdf_gas : str, default=&#39;lognormal&#39;</span>
<span class="sd">            Probability density function to use for the gas bubble size</span>
<span class="sd">            distribution.  Choices are &#39;lognormal&#39; or &#39;rosin-rammler&#39;.</span>
<span class="sd">        pdf_oil : str, default=&#39;rosin-rammler&#39;</span>
<span class="sd">            Probability density function to use for the oil droplet size</span>
<span class="sd">            distribution.  Choices are &#39;lognormal&#39; or &#39;rosin-rammler&#39;.</span>
<span class="sd">        Pa : float, default=4.e6</span>
<span class="sd">            Pressure at the release point.  Used to compute the speed of</span>
<span class="sd">            sound in gas.</span>
<span class="sd">        Ta : float, default=288.15</span>
<span class="sd">            Temperature of the released fluids.  Used to compute the</span>
<span class="sd">            speed of sound of gas.</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        This method does not return any values.  Instead, the computed values</span>
<span class="sd">        are stored as attributes of the class object.  To report the computed</span>
<span class="sd">        values, use the `get`-methods.</span>

<span class="sd">        See Also</span>
<span class="sd">        --------</span>
<span class="sd">        get_d50, get_de_max, get_distributions</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Record the state of the release</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">d0</span> <span class="o">=</span> <span class="n">d0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">m_gas</span> <span class="o">=</span> <span class="n">m_gas</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">m_oil</span> <span class="o">=</span> <span class="n">m_oil</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">model_gas</span> <span class="o">=</span> <span class="n">model_gas</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">model_oil</span> <span class="o">=</span> <span class="n">model_oil</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">pdf_gas</span> <span class="o">=</span> <span class="n">pdf_gas</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">pdf_oil</span> <span class="o">=</span> <span class="n">pdf_oil</span>

        <span class="c1"># Get the gas bubble size distribution</span>
        <span class="k">if</span> <span class="n">model_gas</span> <span class="o">==</span> <span class="s1">&#39;wang_etal&#39;</span><span class="p">:</span>
            <span class="c1"># Get the parameters of the distribution</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">d50_gas</span><span class="p">,</span> <span class="n">m_gas</span><span class="p">,</span> <span class="n">m_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">de_max_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma_ln_gas</span> <span class="o">=</span> \
                <span class="n">psf</span><span class="o">.</span><span class="n">wang_etal</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">d0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">m_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">rho_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mu_gas</span><span class="p">,</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">sigma_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">rho</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mu</span><span class="p">,</span> <span class="n">m_l</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">m_oil</span><span class="p">,</span>
                    <span class="n">rho_l</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">rho_oil</span><span class="p">,</span> <span class="n">P</span><span class="o">=</span><span class="n">Pa</span><span class="p">,</span> <span class="n">T</span><span class="o">=</span><span class="n">Ta</span>
                <span class="p">)</span>
            <span class="k">if</span> <span class="n">pdf_gas</span> <span class="o">==</span> <span class="s1">&#39;rosin-rammler&#39;</span><span class="p">:</span>
                <span class="c1"># Convert lognormal parameters to Rosin-Rammler</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">d50_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma_gas</span> <span class="o">=</span> <span class="n">psf</span><span class="o">.</span><span class="n">ln2rr</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">d50_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma_ln_gas</span>
                    <span class="p">)</span>
        <span class="k">elif</span> <span class="n">model_gas</span> <span class="o">==</span> <span class="s1">&#39;li_etal&#39;</span><span class="p">:</span>
            <span class="c1"># Get the parameters of the distribution</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">d50_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">de_max_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">alpha_gas</span> <span class="o">=</span> \
                <span class="n">psf</span><span class="o">.</span><span class="n">li_etal</span><span class="p">(</span>
                   <span class="bp">self</span><span class="o">.</span><span class="n">d0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">m_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">rho_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">m_oil</span><span class="p">,</span>
                   <span class="bp">self</span><span class="o">.</span><span class="n">rho_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mu_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">rho</span><span class="p">,</span>
                   <span class="bp">self</span><span class="o">.</span><span class="n">mu</span><span class="p">,</span> <span class="n">fp_type</span><span class="o">=</span><span class="mi">0</span>
                <span class="p">)</span>
            <span class="k">if</span> <span class="n">pdf_gas</span> <span class="o">==</span> <span class="s1">&#39;lognormal&#39;</span><span class="p">:</span>
                <span class="c1"># Convert Rosin-Rammler parameters to lognormal</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">d50_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma_ln_gas</span> <span class="o">=</span> <span class="n">psf</span><span class="o">.</span><span class="n">rr2ln</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">d50_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">alpha_gas</span>
                    <span class="p">)</span>

        <span class="c1"># Get the oil droplet size distribution</span>
        <span class="k">if</span> <span class="n">model_oil</span> <span class="o">==</span> <span class="s1">&#39;sintef&#39;</span><span class="p">:</span>
            <span class="c1"># Get the parameters of the distribution</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">d50_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">de_max_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">alpha_oil</span> <span class="o">=</span> \
                <span class="n">psf</span><span class="o">.</span><span class="n">sintef</span><span class="p">(</span>
                   <span class="bp">self</span><span class="o">.</span><span class="n">d0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">m_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">rho_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">m_oil</span><span class="p">,</span>
                   <span class="bp">self</span><span class="o">.</span><span class="n">rho_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mu_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">rho</span><span class="p">,</span>
                   <span class="bp">self</span><span class="o">.</span><span class="n">mu</span><span class="p">,</span> <span class="n">fp_type</span><span class="o">=</span><span class="mi">1</span>
                <span class="p">)</span>
        <span class="k">elif</span> <span class="n">model_oil</span> <span class="o">==</span> <span class="s1">&#39;li_etal&#39;</span><span class="p">:</span>
            <span class="c1"># Get the parameters of the distribution</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">d50_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">de_max_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">alpha_oil</span> <span class="o">=</span> \
                <span class="n">psf</span><span class="o">.</span><span class="n">li_etal</span><span class="p">(</span>
                   <span class="bp">self</span><span class="o">.</span><span class="n">d0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">m_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">rho_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">m_oil</span><span class="p">,</span>
                   <span class="bp">self</span><span class="o">.</span><span class="n">rho_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mu_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">rho</span><span class="p">,</span>
                   <span class="bp">self</span><span class="o">.</span><span class="n">mu</span><span class="p">,</span> <span class="n">fp_type</span><span class="o">=</span><span class="mi">1</span>
                <span class="p">)</span>
        <span class="k">if</span> <span class="n">pdf_oil</span> <span class="o">==</span> <span class="s1">&#39;lognormal&#39;</span><span class="p">:</span>
            <span class="c1"># Convert Rosin-Rammler parameters to lognormal</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">d50_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma_ln_oil</span> <span class="o">=</span> <span class="n">psf</span><span class="o">.</span><span class="n">rr2ln</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">d50_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">alpha_oil</span>
                <span class="p">)</span>

        <span class="c1"># Set the simulation flag to True</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="ModelBase.get_de_max"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.ModelBase.get_de_max.html#particle_size_models.ModelBase.get_de_max">[docs]</a>    <span class="k">def</span> <span class="nf">get_de_max</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fp_type</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Report the maximum stable particle size of a fluid at the release</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fp_type : int</span>
<span class="sd">            Fluid for which the maximum stable particle size is desired:</span>
<span class="sd">            0 = gas, 1 = liquid.</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        de_max : float</span>
<span class="sd">            Equivalent spherical diameter of the maximum stable particle</span>
<span class="sd">            size (m)</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span><span class="p">:</span>
            <span class="c1"># Use the simulated values stored in the present object</span>
            <span class="k">if</span> <span class="n">fp_type</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">de_max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">de_max_gas</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">de_max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">de_max_oil</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># Compute new values since these are independent of orifice</span>
            <span class="c1"># conditions</span>
            <span class="k">if</span> <span class="n">fp_type</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="c1"># Get maximum stable particle size for gas</span>
                <span class="n">de_max</span> <span class="o">=</span> <span class="n">psf</span><span class="o">.</span><span class="n">grace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">rho</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">rho_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mu</span><span class="p">,</span>
                                   <span class="bp">self</span><span class="o">.</span><span class="n">mu_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma_gas</span><span class="p">,</span> <span class="n">fp_type</span><span class="p">)</span>
            <span class="k">elif</span> <span class="n">fp_type</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                <span class="c1"># Get the maximum stable particle size for oil</span>
                <span class="n">de_max</span> <span class="o">=</span> <span class="n">psf</span><span class="o">.</span><span class="n">de_max_oil</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">rho_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma_oil</span><span class="p">,</span>
                                        <span class="bp">self</span><span class="o">.</span><span class="n">rho</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">de_max</span></div>

<div class="viewcode-block" id="ModelBase.get_d50"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.ModelBase.get_d50.html#particle_size_models.ModelBase.get_d50">[docs]</a>    <span class="k">def</span> <span class="nf">get_d50</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fp_type</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Report the median particle size of a fluid at the release</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fp_type : int</span>
<span class="sd">            Fluid for which the maximum stable particle size is desired:</span>
<span class="sd">            0 = gas, 1 = liquid.</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        d50 : float</span>
<span class="sd">            Equivalent spherical diameter of the median particle size of</span>
<span class="sd">            the volume size distribution (m)</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        This method uses the parameters of the particle size distributions</span>
<span class="sd">        determined by the `simulate()` method of the object.  You must</span>
<span class="sd">        run this method before calling this method to create the particle</span>
<span class="sd">        size distributions.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">fp_type</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">d50</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">d50_gas</span>
            <span class="k">elif</span> <span class="n">fp_type</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                <span class="n">d50</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">d50_oil</span>
            <span class="k">return</span> <span class="n">d50</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;You should run the .simulate() method first&quot;</span><span class="p">)</span>
            <span class="k">return</span> <span class="mi">0</span></div>

<div class="viewcode-block" id="ModelBase.get_distributions"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.ModelBase.get_distributions.html#particle_size_models.ModelBase.get_distributions">[docs]</a>    <span class="k">def</span> <span class="nf">get_distributions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">nbins_gas</span><span class="p">,</span> <span class="n">nbins_oil</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Report the bubble and droplet size distributions</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        nbins_gas : int</span>
<span class="sd">            Number of bin sizes to use in the gas bubble volume size</span>
<span class="sd">            distribution</span>
<span class="sd">        nbins_oil : int</span>
<span class="sd">            Number of bin sizes to use in the oil droplet volume size</span>
<span class="sd">            distribution</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        de_gas : ndarray</span>
<span class="sd">            Array of equivalent spherical diameters of bubbles in the bubble</span>
<span class="sd">            size distribution (log-distributed, m)</span>
<span class="sd">        vf_gas : ndarray</span>
<span class="sd">            Array of volume fractions of gas corresponding to each bubble size</span>
<span class="sd">            in the  `de_gas` bubble size distribution (--)</span>
<span class="sd">        de_oil : ndarray</span>
<span class="sd">            Array of equivalent spherical diameters of droplets in the droplet</span>
<span class="sd">            size distribution (log-distributed, m)</span>
<span class="sd">        vf_oil : ndarray</span>
<span class="sd">            Array of volume fractions of oil corresponding to each droplet</span>
<span class="sd">            size in the `de_oil` droplet size distribution (--)</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        This method uses the parameters of the particle size distributions</span>
<span class="sd">        determined by the `simulate()` method of the object.  You must</span>
<span class="sd">        run this method before calling this method to create the particle</span>
<span class="sd">        size distributions.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span><span class="p">:</span>
            <span class="c1"># Record the input parameters</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">nbins_gas</span> <span class="o">=</span> <span class="n">nbins_gas</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">nbins_oil</span> <span class="o">=</span> <span class="n">nbins_oil</span>

            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pdf_gas</span> <span class="o">==</span> <span class="s1">&#39;rosin-rammler&#39;</span><span class="p">:</span>
                <span class="c1"># Use Rosin-Rammler directly</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">de_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">vf_gas</span> <span class="o">=</span> <span class="n">psf</span><span class="o">.</span><span class="n">rosin_rammler</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nbins_gas</span><span class="p">,</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">d50_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">alpha_gas</span>
                    <span class="p">)</span>
            <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">pdf_gas</span> <span class="o">==</span> <span class="s1">&#39;lognormal&#39;</span><span class="p">:</span>
                <span class="c1"># Use the fitted lognormal distribution</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">de_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">vf_gas</span> <span class="o">=</span> <span class="n">psf</span><span class="o">.</span><span class="n">log_normal</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nbins_gas</span><span class="p">,</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">d50_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma_ln_gas</span>
                    <span class="p">)</span>

            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pdf_oil</span> <span class="o">==</span> <span class="s1">&#39;rosin-rammler&#39;</span><span class="p">:</span>
                <span class="c1"># Use Rosin-Rammler directly</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">de_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">vf_oil</span> <span class="o">=</span> <span class="n">psf</span><span class="o">.</span><span class="n">rosin_rammler</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nbins_oil</span><span class="p">,</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">d50_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">alpha_oil</span>
                    <span class="p">)</span>
            <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">pdf_oil</span> <span class="o">==</span> <span class="s1">&#39;lognormal&#39;</span><span class="p">:</span>
                <span class="c1"># Use the fitted lognormal distribution</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">de_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">vf_oil</span> <span class="o">=</span> <span class="n">psf</span><span class="o">.</span><span class="n">log_normal</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nbins_oil</span><span class="p">,</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">d50_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma_ln_oil</span>
                    <span class="p">)</span>

            <span class="c1"># Set the distribution flag to true</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">distribution_stored</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;You should run the .simulate() method first&quot;</span><span class="p">)</span>
            <span class="k">return</span> <span class="mi">0</span>

        <span class="k">return</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">de_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">vf_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">de_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">vf_oil</span><span class="p">)</span></div>


<div class="viewcode-block" id="ModelBase.plot_psd"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.ModelBase.plot_psd.html#particle_size_models.ModelBase.plot_psd">[docs]</a>    <span class="k">def</span> <span class="nf">plot_psd</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fig</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">fp_type</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Create plots of the bubble and droplet size distribution</span>

<span class="sd">        Plots a standard presentation of the present gas bubble and oil</span>
<span class="sd">        droplet size distributions</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fig : int, default=1</span>
<span class="sd">            Figure number to plot</span>
<span class="sd">        fp_type : int, default=None</span>
<span class="sd">            Fluid to plot.  If `fp_type` = None, then both the gas bubbles</span>
<span class="sd">            and liquid droplets are plotted.  Otherwise, only the</span>
<span class="sd">            distribution defined by this parameter is plotted:  0 = gas,</span>
<span class="sd">            1 = liquid.</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        This method relies on the distribution already being computed,</span>
<span class="sd">        which requires first calling the methods `simulate()` and</span>
<span class="sd">        `get_distributions()`.  If these have not been computed, an</span>
<span class="sd">        error message will display and not plots will be created.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span><span class="p">:</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">distribution_stored</span><span class="p">:</span>
                <span class="c1"># Prepare to plot d50 only</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">get_distributions</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>

            <span class="c1"># Create the standard plots for gas and oil size distributions</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">fig</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>

            <span class="n">title_font</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;fontsize&#39;</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span>
                          <span class="s1">&#39;fontweight&#39;</span> <span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
                          <span class="s1">&#39;verticalalignment&#39;</span><span class="p">:</span> <span class="s1">&#39;baseline&#39;</span><span class="p">,</span>
                          <span class="s1">&#39;horizontalalignment&#39;</span><span class="p">:</span> <span class="s1">&#39;left&#39;</span><span class="p">}</span>

            <span class="c1"># Gas bubble distribution</span>
            <span class="k">if</span> <span class="n">fp_type</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">fp_type</span> <span class="o">==</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">211</span><span class="p">)</span>
                <span class="n">plot_phase</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nbins_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">de_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">vf_gas</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">)</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;Gas bubble diameter (mm)&#39;</span><span class="p">)</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s1">&#39;Gas mass flux (kg/s)&#39;</span><span class="p">)</span>
                <span class="n">fig_title</span> <span class="o">=</span> <span class="s1">&#39; Gas model = &#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">model_gas</span> <span class="o">+</span> \
                            <span class="s1">&#39;; PDF = &#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">pdf_gas</span> <span class="o">+</span> \
                            <span class="s1">&#39;; d_50 = &#39;</span> <span class="o">+</span> \
                            <span class="s1">&#39;</span><span class="si">%2.2f</span><span class="s1"> mm&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_d50</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">*</span> <span class="mf">1000.</span><span class="p">)</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="n">fig_title</span><span class="p">,</span> <span class="n">loc</span><span class="o">=</span><span class="s1">&#39;left&#39;</span><span class="p">,</span> <span class="n">fontdict</span><span class="o">=</span><span class="n">title_font</span><span class="p">,</span> <span class="n">pad</span><span class="o">=-</span><span class="mi">35</span><span class="p">)</span>

            <span class="c1"># Oil droplet distribution</span>
            <span class="k">if</span> <span class="n">fp_type</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">or</span> <span class="n">fp_type</span> <span class="o">==</span> <span class="kc">None</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">fp_type</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">211</span><span class="p">)</span>
                <span class="k">elif</span> <span class="n">fp_type</span> <span class="o">==</span> <span class="kc">None</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">212</span><span class="p">)</span>
                <span class="n">plot_phase</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nbins_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">de_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">vf_oil</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;Oil droplet diameter (mm)&#39;</span><span class="p">)</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s1">&#39;Oil mass flux (kg/s)&#39;</span><span class="p">)</span>
                <span class="n">fig_title</span> <span class="o">=</span> <span class="s1">&#39; Oil model = &#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">model_oil</span> <span class="o">+</span> \
                            <span class="s1">&#39;; PDF = &#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">pdf_oil</span> <span class="o">+</span> \
                            <span class="s1">&#39;; d_50 = &#39;</span> <span class="o">+</span> \
                            <span class="s1">&#39;</span><span class="si">%2.2f</span><span class="s1"> mm&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_d50</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="mf">1000.</span><span class="p">)</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="n">fig_title</span><span class="p">,</span> <span class="n">loc</span><span class="o">=</span><span class="s1">&#39;left&#39;</span><span class="p">,</span> <span class="n">fontdict</span><span class="o">=</span><span class="n">title_font</span><span class="p">,</span>
                          <span class="n">pad</span><span class="o">=-</span><span class="mi">35</span><span class="p">)</span>

            <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;You should run the .simulate() and .get_distribution()&quot;</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;methods first&quot;</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="PureJet"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.PureJet.html#particle_size_models.PureJet">[docs]</a><span class="k">class</span> <span class="nc">PureJet</span><span class="p">(</span><span class="n">ModelBase</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class object for pure gas or pure oil plumes</span>

<span class="sd">    This class uses the `ModelBase` class, but provides an interface that</span>
<span class="sd">    only expects one released fluid (based on `fp_type`; 0 = gas,</span>
<span class="sd">    1 = liquid).</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    rho_p : float</span>
<span class="sd">        Density of the gas phase released from the jet (kg/m^3)</span>
<span class="sd">    mu_p : float</span>
<span class="sd">        Dynamic viscosity of the gas phase released from the jet (Pa s)</span>
<span class="sd">    sigma_p : float</span>
<span class="sd">        Interfacial tension between the gas phase released from the jet and</span>
<span class="sd">        the continuous-phase receiving fluid (N/m)</span>
<span class="sd">    rho : float</span>
<span class="sd">        Density of the continuous-phase receiving fluid (kg/m^3)</span>
<span class="sd">    mu : float</span>
<span class="sd">        Dynamic viscosity of the continuous-phase receiving fluid (Pa s)</span>
<span class="sd">    fp_type : int, default=1</span>
<span class="sd">        Phase of the released fluid; 0 = gas, 1 = liquid.</span>

<span class="sd">    Attributes</span>
<span class="sd">    ----------</span>
<span class="sd">    rho_gas : float</span>
<span class="sd">        Density of the gas phase released from the jet (kg/m^3)</span>
<span class="sd">    mu_gas : float</span>
<span class="sd">        Dynamic viscosity of the gas phase released from the jet (Pa s)</span>
<span class="sd">    sigma_gas : float</span>
<span class="sd">        Interfacial tension between the gas phase released from the jet and</span>
<span class="sd">        the continuous-phase receiving fluid (N/m)</span>
<span class="sd">    rho_oil : float</span>
<span class="sd">        Density of the liquid phase released from the jet (kg/m^3)</span>
<span class="sd">    mu_oil : float</span>
<span class="sd">        Dynamic viscosity of the liquid phase released from the jet (Pa s)</span>
<span class="sd">    sigma_oil : float</span>
<span class="sd">        Interfacial tension between the liquid phase released from the jet</span>
<span class="sd">        and the continuous-phase receiving fluid (N/m)</span>
<span class="sd">    rho : float</span>
<span class="sd">        Density of the continuous-phase receiving fluid (kg/m^3)</span>
<span class="sd">    mu : float</span>
<span class="sd">        Dynamic viscosity of the continuous-phase receiving fluid (Pa s)</span>
<span class="sd">    sim_stored : bool</span>
<span class="sd">        Flag indicating whether or not the particle size distribution</span>
<span class="sd">        algorithm has been calculated since the last property update.</span>
<span class="sd">    distribution_stored : bool</span>
<span class="sd">        Flag indicating whether or not the particle size distribution has</span>
<span class="sd">        been computed and stored since the last property update.</span>
<span class="sd">    d0 : float</span>
<span class="sd">        Equivalent circular diameter of the release orifice (m)</span>
<span class="sd">    m_gas : float</span>
<span class="sd">        Mass flow rate of gas released from the jet (kg/s)</span>
<span class="sd">    m_oil : float</span>
<span class="sd">        Mass flow rate of liquid released from the jet (kg/s)</span>
<span class="sd">    model_gas : str</span>
<span class="sd">        Name of the model used for computing the gas bubble size</span>
<span class="sd">        distribution.  Choices are &#39;wang_etal&#39; or &#39;li_etal&#39;:.</span>
<span class="sd">    model_oil : str</span>
<span class="sd">        Name of the model used for computing the oil droplet size</span>
<span class="sd">        distribution.  Choices are &#39;sintef&#39; or &#39;li_etal&#39;.</span>
<span class="sd">    pdf_gas : str</span>
<span class="sd">        Probability density function to use for the gas bubble size</span>
<span class="sd">        distribution.  Choices are &#39;lognormal&#39; or &#39;rosin-rammler&#39;.</span>
<span class="sd">    pdf_oil : str</span>
<span class="sd">        Probability density function to use for the oil droplet size</span>
<span class="sd">        distribution.  Choices are &#39;lognormal&#39; or &#39;rosin-rammler&#39;.</span>
<span class="sd">    d50_gas : float</span>
<span class="sd">        Median equivalent spherical diameter of gas bubbles (m)</span>
<span class="sd">    de_max_gas : float</span>
<span class="sd">        Maximum stable bubble size (equivalent spherical diameter) of gas</span>
<span class="sd">        bubbles (m).</span>
<span class="sd">    de_gas : ndarray</span>
<span class="sd">        Array of equivalent spherical diameters of bubbles in the bubble</span>
<span class="sd">        size distribution (log-distributed, m)</span>
<span class="sd">    vf_gas : ndarray</span>
<span class="sd">        Array of volume fractions of gas corresponding to each bubble size</span>
<span class="sd">        in the  `de_gas` bubble size distribution (--)</span>
<span class="sd">    d50_oil : float</span>
<span class="sd">        Median equivalent spherical diameter of oil droplets (m)</span>
<span class="sd">    de_max_oil : float</span>
<span class="sd">        Maximum stable droplet size (equivalent spherical diameter) of oil</span>
<span class="sd">        droplets (m).</span>
<span class="sd">    de_oil : ndarray</span>
<span class="sd">        Array of equivalent spherical diameters of droplets in the droplet</span>
<span class="sd">        size distribution (log-distributed, m)</span>
<span class="sd">    vf_oil : ndarray</span>
<span class="sd">        Array of volume fractions of oil corresponding to each droplet size</span>
<span class="sd">        in the  `de_oil` droplet size distribution (--)</span>

<span class="sd">    See Also</span>
<span class="sd">    --------</span>
<span class="sd">    ModelBase, Model</span>

<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    In the attributes above, the attributes attached to the fluid phase of</span>
<span class="sd">    interest will have values; whereas, the other phase will contain `None`.</span>
<span class="sd">    For example, if this is a pure oil release, `rho_oil` will have a value,</span>
<span class="sd">    but `rho_gas` will store `None`.</span>

<span class="sd">    &quot;&quot;&quot;</span>
<div class="viewcode-block" id="PureJet.__init__"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.PureJet.html#particle_size_models.PureJet.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">rho_p</span><span class="p">,</span> <span class="n">mu_p</span><span class="p">,</span> <span class="n">sigma_p</span><span class="p">,</span> <span class="n">rho</span><span class="p">,</span> <span class="n">mu</span><span class="p">,</span> <span class="n">fp_type</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>

        <span class="c1"># Send the particle properties to the correct phase</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">update_properties</span><span class="p">(</span><span class="n">rho_p</span><span class="p">,</span> <span class="n">mu_p</span><span class="p">,</span> <span class="n">sigma_p</span><span class="p">,</span> <span class="n">rho</span><span class="p">,</span> <span class="n">mu</span><span class="p">,</span> <span class="n">fp_type</span><span class="p">)</span></div>

<div class="viewcode-block" id="PureJet.update_properties"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.PureJet.update_properties.html#particle_size_models.PureJet.update_properties">[docs]</a>    <span class="k">def</span> <span class="nf">update_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">rho_p</span><span class="p">,</span> <span class="n">mu_p</span><span class="p">,</span> <span class="n">sigma_p</span><span class="p">,</span> <span class="n">rho</span><span class="p">,</span> <span class="n">mu</span><span class="p">,</span> <span class="n">fp_type</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Set the thermodynamic properties of the release and receiving fluids</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        rho_p : float</span>
<span class="sd">            Density of the gas phase released from the jet (kg/m^3)</span>
<span class="sd">        mu_p : float</span>
<span class="sd">            Dynamic viscosity of the gas phase released from the jet (Pa s)</span>
<span class="sd">        sigma_p : float</span>
<span class="sd">            Interfacial tension between the gas phase released from the jet</span>
<span class="sd">            and the continuous-phase receiving fluid (N/m)</span>
<span class="sd">        rho : float</span>
<span class="sd">            Density of the continuous-phase receiving fluid (kg/m^3)</span>
<span class="sd">        mu : float</span>
<span class="sd">            Dynamic viscosity of the continuous-phase receiving fluid (Pa s)</span>
<span class="sd">        fp_type : int, default=1</span>
<span class="sd">            Phase of the released fluid; 0 = gas, 1 = liquid.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Set the flags initially to False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">distribution_stored</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="c1"># Record the fluid type</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">fp_type</span> <span class="o">=</span> <span class="n">fp_type</span>

        <span class="c1"># Send the particle properties to the correct phase</span>
        <span class="k">if</span> <span class="n">fp_type</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">ModelBase</span><span class="o">.</span><span class="n">update_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">rho_p</span><span class="p">,</span> <span class="n">mu_p</span><span class="p">,</span> <span class="n">sigma_p</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span>
                <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="n">rho</span><span class="p">,</span> <span class="n">mu</span><span class="p">)</span>

        <span class="k">elif</span> <span class="n">fp_type</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
            <span class="n">ModelBase</span><span class="o">.</span><span class="n">update_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="n">rho_p</span><span class="p">,</span> <span class="n">mu_p</span><span class="p">,</span>
                <span class="n">sigma_p</span><span class="p">,</span> <span class="n">rho</span><span class="p">,</span> <span class="n">mu</span><span class="p">)</span></div>

<div class="viewcode-block" id="PureJet.simulate"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.PureJet.simulate.html#particle_size_models.PureJet.simulate">[docs]</a>    <span class="k">def</span> <span class="nf">simulate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">d0</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">model</span><span class="o">=</span><span class="s1">&#39;sintef&#39;</span><span class="p">,</span> <span class="n">pdf</span><span class="o">=</span><span class="s1">&#39;rosin-rammler&#39;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Compute the parameters of the particle size distribution</span>

<span class="sd">        Computes the median bubble or droplet sizes and the spread</span>
<span class="sd">        of the selected size distributions.  Models for gas bubble median</span>
<span class="sd">        size are `wang_etal` or `li_etal`; models for oil droplet median</span>
<span class="sd">        size are `sintef` or `li_etal`.  Size distributions are either</span>
<span class="sd">        `lognormal` or `rosin-rammler`.  No matter what model is selected,</span>
<span class="sd">        the `d_95`-rule is used when the predicted size distribution would</span>
<span class="sd">        exceed the maximum stable bubble or droplet size.  Under that rule,</span>
<span class="sd">        the 95-percentile of the volume size distribution is set to the</span>
<span class="sd">        maximum stable size, and the median size is adjusted downward.</span>

<span class="sd">        This method only computes size distribution values for the fluid</span>
<span class="sd">        type selected by the class attribute fp_type (0 = gas, 1 = liquid).</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        d0 : float</span>
<span class="sd">            Equivalent circular diameter of the release orifice (m)</span>
<span class="sd">        m : float</span>
<span class="sd">            Mass flow rate of fluid released from the jet (kg/s)</span>
<span class="sd">        model : str, default=&#39;wang_etal&#39;</span>
<span class="sd">            Name of the model used for computing the particle size</span>
<span class="sd">            distribution.  Choices are &#39;wang_etal&#39;, &#39;li_etal&#39;, or &#39;sintef&#39;.</span>
<span class="sd">            Note that the model choice must agree with the fluid of interest;</span>
<span class="sd">            see paragraph above for details.</span>
<span class="sd">        pdf : str, default=&#39;rosin-rammler&#39;</span>
<span class="sd">            Probability density function to use for the particle size</span>
<span class="sd">            distribution.  Choices are &#39;lognormal&#39; or &#39;rosin-rammler&#39;.</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        This method does not return any values.  Instead, the computed values</span>
<span class="sd">        are stored as attributes of the class object.  To report the computed</span>
<span class="sd">        values, use the `get`-methods.</span>

<span class="sd">        See Also</span>
<span class="sd">        --------</span>
<span class="sd">        get_d50, get_de_max, get_distributions</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fp_type</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">ModelBase</span><span class="o">.</span><span class="n">simulate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">d0</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">0.</span><span class="p">]),</span> <span class="n">model_gas</span><span class="o">=</span><span class="n">model</span><span class="p">,</span>
                               <span class="n">pdf_gas</span><span class="o">=</span><span class="n">pdf</span><span class="p">)</span>
        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">fp_type</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
            <span class="n">ModelBase</span><span class="o">.</span><span class="n">simulate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">d0</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">0.</span><span class="p">]),</span> <span class="n">m</span><span class="p">,</span> <span class="n">model_oil</span><span class="o">=</span><span class="n">model</span><span class="p">,</span>
                               <span class="n">pdf_oil</span><span class="o">=</span><span class="n">pdf</span><span class="p">)</span></div>

<div class="viewcode-block" id="PureJet.get_de_max"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.PureJet.get_de_max.html#particle_size_models.PureJet.get_de_max">[docs]</a>    <span class="k">def</span> <span class="nf">get_de_max</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fp_type</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Report the maximum stable particle size of the fluid at the release</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        de_max : float</span>
<span class="sd">            Equivalent spherical diameter of the maximum stable particle</span>
<span class="sd">            size (m)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">ModelBase</span><span class="o">.</span><span class="n">get_de_max</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">fp_type</span><span class="p">)</span></div>

<div class="viewcode-block" id="PureJet.get_d50"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.PureJet.get_d50.html#particle_size_models.PureJet.get_d50">[docs]</a>    <span class="k">def</span> <span class="nf">get_d50</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fp_type</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Report the median particle size of a fluid at the release</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        d50 : float</span>
<span class="sd">            Equivalent spherical diameter of the median particle size of</span>
<span class="sd">            the volume size distribution (m)</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        This method uses the parameters of the particle size distributions</span>
<span class="sd">        determined by the `simulate()` method of the object.  You must</span>
<span class="sd">        run this method before calling this method to create the particle</span>
<span class="sd">        size distributions.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">ModelBase</span><span class="o">.</span><span class="n">get_d50</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">fp_type</span><span class="p">)</span></div>

<div class="viewcode-block" id="PureJet.get_distributions"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.PureJet.get_distributions.html#particle_size_models.PureJet.get_distributions">[docs]</a>    <span class="k">def</span> <span class="nf">get_distributions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">nbins</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Report the particle size distributions</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        nbins : int</span>
<span class="sd">            Number of bin sizes to use in the volume size distribution</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        de : ndarray</span>
<span class="sd">            Array of equivalent spherical diameters of particles in the</span>
<span class="sd">            volume size distribution (log-distributed, m)</span>
<span class="sd">        vf : ndarray</span>
<span class="sd">            Array of volume fractions of particles corresponding to each</span>
<span class="sd">            particle size in the  `de` volume size distribution (--)</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        This method uses the parameters of the particle size distributions</span>
<span class="sd">        determined by the `simulate()` method of the object.  You must</span>
<span class="sd">        run this method before calling this method to create the particle</span>
<span class="sd">        size distributions.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Compute the appropriate distribution</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fp_type</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">de</span><span class="p">,</span> <span class="n">vf</span><span class="p">,</span> <span class="n">de_none</span><span class="p">,</span> <span class="n">vf_none</span> <span class="o">=</span> <span class="n">ModelBase</span><span class="o">.</span><span class="n">get_distributions</span><span class="p">(</span>
                    <span class="bp">self</span><span class="p">,</span> <span class="n">nbins</span><span class="p">,</span> <span class="mi">0</span>
                <span class="p">)</span>
        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">fp_type</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
            <span class="n">de_none</span><span class="p">,</span> <span class="n">vf_none</span><span class="p">,</span> <span class="n">de</span><span class="p">,</span> <span class="n">vf</span> <span class="o">=</span> <span class="n">ModelBase</span><span class="o">.</span><span class="n">get_distributions</span><span class="p">(</span>
                    <span class="bp">self</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">nbins</span>
                <span class="p">)</span>

        <span class="k">return</span> <span class="p">(</span><span class="n">de</span><span class="p">,</span> <span class="n">vf</span><span class="p">)</span></div>

<div class="viewcode-block" id="PureJet.plot_psd"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.PureJet.plot_psd.html#particle_size_models.PureJet.plot_psd">[docs]</a>    <span class="k">def</span> <span class="nf">plot_psd</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fig_num</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Create a plot of the particle size distribution</span>

<span class="sd">        Plots a standard presentation of the present particle size</span>
<span class="sd">        distribution</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fig_num : int, default=1</span>
<span class="sd">            Figure number to plot</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        This method relies on the distribution already being computed,</span>
<span class="sd">        which requires first calling the methods `simulate()` and</span>
<span class="sd">        `get_distributions()`.  If these have not been computed, an</span>
<span class="sd">        error message will display and not plots will be created.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">ModelBase</span><span class="o">.</span><span class="n">plot_psd</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fig_num</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">fp_type</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="Model"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.Model.html#particle_size_models.Model">[docs]</a><span class="k">class</span> <span class="nc">Model</span><span class="p">(</span><span class="n">ModelBase</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Master lass object for computing bubble and droplet size distributions</span>

<span class="sd">    This model class contains handles the interface to the `ModelBase`,</span>
<span class="sd">    allowing particle size distributions to be easily computed given a</span>
<span class="sd">    `dbm.FluidMixture` description of the released fluids.  This is the</span>
<span class="sd">    main class object that should be used to compute bubble and droplet</span>
<span class="sd">    size distributions for the plume models in ``TAMOC``.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    profile : `ambient.Profile` object</span>
<span class="sd">        Profile containing ambient CTD data</span>
<span class="sd">    oil_mixture : `dbm.FluidMixture` object</span>
<span class="sd">        A `dbm.FluidMixture` object that contains the chemical description</span>
<span class="sd">        of an oil mixture.</span>
<span class="sd">    m_mixture : ndarray</span>
<span class="sd">        An array of mass fluxes (kg/s) of each pseudo-component in the live-</span>
<span class="sd">        oil mixture.</span>
<span class="sd">    z0 : float</span>
<span class="sd">        Release point of the jet orifice (m)</span>
<span class="sd">    Tj : float</span>
<span class="sd">        Temperature of the released fluids (K)</span>

<span class="sd">    Attributes</span>
<span class="sd">    ----------</span>
<span class="sd">    profile : `ambient.Profile` object</span>
<span class="sd">        Profile containing ambient CTD data</span>
<span class="sd">    oil_mixture : `dbm.FluidMixture` object</span>
<span class="sd">        A `dbm.FluidMixture` object that contains the chemical description</span>
<span class="sd">        of an oil mixture.</span>
<span class="sd">    m_mixture : ndarray</span>
<span class="sd">        An array of mass fluxes (kg/s) of each pseudo-component in the live-</span>
<span class="sd">        oil mixture.</span>
<span class="sd">    z0 : float</span>
<span class="sd">        Release point of the jet orifice (m)</span>
<span class="sd">    Tj : float</span>
<span class="sd">        Temperature of the released fluids (K)</span>
<span class="sd">    T : float</span>
<span class="sd">        Temperature of the receiving fluid at the release (K)</span>
<span class="sd">    S : float</span>
<span class="sd">        Salinity of the receiving fluid at the release (psu)</span>
<span class="sd">    P : float</span>
<span class="sd">        Pressure of the receiving fluid at the release (Pa)</span>
<span class="sd">    gas : `dbm.FluidParticle` object</span>
<span class="sd">        A `dbm.FluidParticle` object for the gas phase fluid at the</span>
<span class="sd">        release</span>
<span class="sd">    m_gas : ndarray</span>
<span class="sd">        An array of mass fluxes (kg/s) of each pseudo-component in the gas</span>
<span class="sd">        phase of the released fluids.</span>
<span class="sd">    rho_gas : float</span>
<span class="sd">        Density of the gas phase released from the jet (kg/m^3)</span>
<span class="sd">    mu_gas : float</span>
<span class="sd">        Dynamic viscosity of the gas phase released from the jet (Pa s)</span>
<span class="sd">    sigma_gas : float</span>
<span class="sd">        Interfacial tension between the gas phase released from the jet and</span>
<span class="sd">        the continuous-phase receiving fluid (N/m)</span>
<span class="sd">    oil : `dbm.FluidParticle` object</span>
<span class="sd">        A `dbm.FluidParticle` object for the liquid phase fluid at the</span>
<span class="sd">        release</span>
<span class="sd">    m_oil : ndarray</span>
<span class="sd">        An array of mass fluxes (kg/s) of each pseudo-component in the liquid</span>
<span class="sd">        phase of the released fluids.</span>
<span class="sd">    rho_oil : float</span>
<span class="sd">        Density of the liquid phase released from the jet (kg/m^3)</span>
<span class="sd">    mu_oil : float</span>
<span class="sd">        Dynamic viscosity of the liquid phase released from the jet (Pa s)</span>
<span class="sd">    sigma_oil : float</span>
<span class="sd">        Interfacial tension between the liquid phase released from the jet</span>
<span class="sd">        and the continuous-phase receiving fluid (N/m)</span>
<span class="sd">    rho : float</span>
<span class="sd">        Density of the continuous-phase receiving fluid (kg/m^3)</span>
<span class="sd">    mu : float</span>
<span class="sd">        Dynamic viscosity of the continuous-phase receiving fluid (Pa s)</span>
<span class="sd">    sim_stored : bool</span>
<span class="sd">        Flag indicating whether or not the particle size distribution</span>
<span class="sd">        algorithm has been calculated since the last property update.</span>
<span class="sd">    distribution_stored : bool</span>
<span class="sd">        Flag indicating whether or not the particle size distribution has</span>
<span class="sd">        been computed and stored since the last property update.</span>
<span class="sd">    d0 : float</span>
<span class="sd">        Equivalent circular diameter of the release orifice (m)</span>
<span class="sd">    m_gas : float</span>
<span class="sd">        Mass flow rate of gas released from the jet (kg/s)</span>
<span class="sd">    m_oil : float</span>
<span class="sd">        Mass flow rate of liquid released from the jet (kg/s)</span>
<span class="sd">    model_gas : str</span>
<span class="sd">        Name of the model used for computing the gas bubble size</span>
<span class="sd">        distribution.  Choices are &#39;wang_etal&#39; or &#39;li_etal&#39;:.</span>
<span class="sd">    model_oil : str</span>
<span class="sd">        Name of the model used for computing the oil droplet size</span>
<span class="sd">        distribution.  Choices are &#39;sintef&#39; or &#39;li_etal&#39;.</span>
<span class="sd">    pdf_gas : str</span>
<span class="sd">        Probability density function to use for the gas bubble size</span>
<span class="sd">        distribution.  Choices are &#39;lognormal&#39; or &#39;rosin-rammler&#39;.</span>
<span class="sd">    pdf_oil : str</span>
<span class="sd">        Probability density function to use for the oil droplet size</span>
<span class="sd">        distribution.  Choices are &#39;lognormal&#39; or &#39;rosin-rammler&#39;.</span>
<span class="sd">    d50_gas : float</span>
<span class="sd">        Median equivalent spherical diameter of gas bubbles (m)</span>
<span class="sd">    de_max_gas : float</span>
<span class="sd">        Maximum stable bubble size (equivalent spherical diameter) of gas</span>
<span class="sd">        bubbles (m).</span>
<span class="sd">    de_gas : ndarray</span>
<span class="sd">        Array of equivalent spherical diameters of bubbles in the bubble</span>
<span class="sd">        size distribution (log-distributed, m)</span>
<span class="sd">    vf_gas : ndarray</span>
<span class="sd">        Array of volume fractions of gas corresponding to each bubble size</span>
<span class="sd">        in the  `de_gas` bubble size distribution (--)</span>
<span class="sd">    d50_oil : float</span>
<span class="sd">        Median equivalent spherical diameter of oil droplets (m)</span>
<span class="sd">    de_max_oil : float</span>
<span class="sd">        Maximum stable droplet size (equivalent spherical diameter) of oil</span>
<span class="sd">        droplets (m).</span>
<span class="sd">    de_oil : ndarray</span>
<span class="sd">        Array of equivalent spherical diameters of droplets in the droplet</span>
<span class="sd">        size distribution (log-distributed, m)</span>
<span class="sd">    vf_oil : ndarray</span>
<span class="sd">        Array of volume fractions of oil corresponding to each droplet size</span>
<span class="sd">        in the  `de_oil` droplet size distribution (--)</span>

<span class="sd">    See Also</span>
<span class="sd">    --------</span>
<span class="sd">    ModelBase</span>

<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    This is the main class object that should be used for particle size</span>
<span class="sd">    distributions using the ``TAMOC`` plume models.</span>

<span class="sd">    &quot;&quot;&quot;</span>
<div class="viewcode-block" id="Model.__init__"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.Model.html#particle_size_models.Model.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">profile</span><span class="p">,</span> <span class="n">oil</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">z0</span><span class="p">,</span> <span class="n">Tj</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>

        <span class="c1"># Compute and store the oil properties</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">update_properties</span><span class="p">(</span><span class="n">profile</span><span class="p">,</span> <span class="n">oil</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">z0</span><span class="p">,</span> <span class="n">Tj</span><span class="p">)</span></div>

<div class="viewcode-block" id="Model.update_properties"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.Model.update_properties.html#particle_size_models.Model.update_properties">[docs]</a>    <span class="k">def</span> <span class="nf">update_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">profile</span><span class="p">,</span> <span class="n">oil_mixture</span><span class="p">,</span> <span class="n">m_mixture</span><span class="p">,</span> <span class="n">z0</span><span class="p">,</span> <span class="n">Tj</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Set the thermodynamic properties of the released and receiving fluids</span>

<span class="sd">        Store the density, viscosity, and interfacial tension of the fluids</span>
<span class="sd">        involved in a jet breakup scenario.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        profile : `ambient.Profile` object</span>
<span class="sd">            Profile containing ambient CTD data</span>
<span class="sd">        oil_mixture : `dbm.FluidMixture` object</span>
<span class="sd">            A `dbm.FluidMixture` object that contains the chemical description</span>
<span class="sd">            of an oil mixture.</span>
<span class="sd">        m_mixture : ndarray</span>
<span class="sd">            An array of mass fluxes (kg/s) of each pseudo-component in the</span>
<span class="sd">            live-oil mixture.</span>
<span class="sd">        z0 : float</span>
<span class="sd">            Release point of the jet orifice (m)</span>
<span class="sd">        Tj : float</span>
<span class="sd">            Temperature of the released fluids (K)</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        This method allows the complete release to be redefined.  If you</span>
<span class="sd">        only want to update the release depth or release temperature, use</span>
<span class="sd">        `.update_z0()` or `update_Tj()`, instead.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Set the flags initially to False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">distribution_stored</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="c1"># Record the input parameters</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">profile</span> <span class="o">=</span> <span class="n">profile</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">oil_mixture</span> <span class="o">=</span> <span class="n">oil_mixture</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">m_mixture</span> <span class="o">=</span> <span class="n">m_mixture</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">z0</span> <span class="o">=</span> <span class="n">z0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span> <span class="o">=</span> <span class="n">Tj</span>

        <span class="c1"># Compute the properties of seawater</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">S</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">P</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="o">.</span><span class="n">get_values</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">z0</span><span class="p">,</span>
               <span class="p">[</span><span class="s1">&#39;temperature&#39;</span><span class="p">,</span> <span class="s1">&#39;salinity&#39;</span><span class="p">,</span> <span class="s1">&#39;pressure&#39;</span><span class="p">]</span>
            <span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">rho</span> <span class="o">=</span> <span class="n">seawater</span><span class="o">.</span><span class="n">density</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">S</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">P</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mu</span> <span class="o">=</span> <span class="n">seawater</span><span class="o">.</span><span class="n">mu</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">S</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">P</span><span class="p">)</span>

        <span class="c1"># Set jet temperature either to ambient or input value</span>
        <span class="k">if</span> <span class="n">Tj</span> <span class="o">==</span> <span class="kc">None</span><span class="p">:</span>
            <span class="c1"># Use ambient temperature</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">T</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># Use input temperature</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span> <span class="o">=</span> <span class="n">Tj</span>

        <span class="c1"># Compute the gas/liquid equilibrium</span>
        <span class="n">m_eq</span><span class="p">,</span> <span class="n">xi</span><span class="p">,</span> <span class="n">K</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">oil_mixture</span><span class="o">.</span><span class="n">equilibrium</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">m_mixture</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span><span class="p">,</span>
                                                   <span class="bp">self</span><span class="o">.</span><span class="n">P</span><span class="p">)</span>

        <span class="c1"># Compute the gas phase properties</span>
        <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">m_eq</span><span class="p">[</span><span class="mi">0</span><span class="p">,:])</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">gas</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">m_gas</span> <span class="o">=</span> <span class="n">m_eq</span><span class="p">[</span><span class="mi">0</span><span class="p">,:]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">rho_gas</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">mu_gas</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sigma_gas</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">gas</span> <span class="o">=</span> <span class="n">dbm</span><span class="o">.</span><span class="n">FluidParticle</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">oil_mixture</span><span class="o">.</span><span class="n">composition</span><span class="p">,</span>
                                         <span class="n">fp_type</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span>
                                         <span class="n">delta</span><span class="o">=</span><span class="n">oil_mixture</span><span class="o">.</span><span class="n">delta</span><span class="p">,</span>
                                         <span class="n">user_data</span><span class="o">=</span><span class="n">oil_mixture</span><span class="o">.</span><span class="n">user_data</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">m_gas</span> <span class="o">=</span> <span class="n">m_eq</span><span class="p">[</span><span class="mi">0</span><span class="p">,:]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">rho_gas</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">gas</span><span class="o">.</span><span class="n">density</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">m_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">P</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">mu_gas</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">gas</span><span class="o">.</span><span class="n">viscosity</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">m_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">P</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sigma_gas</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">gas</span><span class="o">.</span><span class="n">interface_tension</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">m_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span><span class="p">,</span>
                                                        <span class="bp">self</span><span class="o">.</span><span class="n">S</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">P</span><span class="p">)</span>

        <span class="c1"># Compute the liquid phase properties</span>
        <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">m_eq</span><span class="p">[</span><span class="mi">1</span><span class="p">,:])</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">oil</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">m_oil</span> <span class="o">=</span> <span class="n">m_eq</span><span class="p">[</span><span class="mi">1</span><span class="p">,:]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">rho_oil</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">mu_oil</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sigma_oil</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">oil</span> <span class="o">=</span> <span class="n">dbm</span><span class="o">.</span><span class="n">FluidParticle</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">oil_mixture</span><span class="o">.</span><span class="n">composition</span><span class="p">,</span>
                                         <span class="n">fp_type</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
                                         <span class="n">delta</span><span class="o">=</span><span class="n">oil_mixture</span><span class="o">.</span><span class="n">delta</span><span class="p">,</span>
                                         <span class="n">user_data</span><span class="o">=</span><span class="n">oil_mixture</span><span class="o">.</span><span class="n">user_data</span><span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">m_oil</span> <span class="o">=</span> <span class="n">m_eq</span><span class="p">[</span><span class="mi">1</span><span class="p">,:]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">rho_oil</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">oil</span><span class="o">.</span><span class="n">density</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">m_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">P</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">mu_oil</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">oil</span><span class="o">.</span><span class="n">viscosity</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">m_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">P</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sigma_oil</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">oil</span><span class="o">.</span><span class="n">interface_tension</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">m_oil</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span><span class="p">,</span>
                                                    <span class="bp">self</span><span class="o">.</span><span class="n">S</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">P</span><span class="p">)</span></div>

<div class="viewcode-block" id="Model.update_z0"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.Model.update_z0.html#particle_size_models.Model.update_z0">[docs]</a>    <span class="k">def</span> <span class="nf">update_z0</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">z0</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Update the release depth of the jet</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        z0 : float</span>
<span class="sd">            Release point of the jet orifice (m)</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">z0</span> <span class="o">=</span> <span class="n">z0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">update_properties</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">oil_mixture</span><span class="p">,</span>
                               <span class="bp">self</span><span class="o">.</span><span class="n">m_mixture</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">z0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span><span class="p">)</span></div>

<div class="viewcode-block" id="Model.update_Tj"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.Model.update_Tj.html#particle_size_models.Model.update_Tj">[docs]</a>    <span class="k">def</span> <span class="nf">update_Tj</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">Tj</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Update the temperature of the released fluids in the jet</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        Tj : float</span>
<span class="sd">            Temperature of the released fluids (K)</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span> <span class="o">=</span> <span class="n">Tj</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">update_properties</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">oil_mixture</span><span class="p">,</span>
                               <span class="bp">self</span><span class="o">.</span><span class="n">m_mixture</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">z0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span><span class="p">)</span></div>

<div class="viewcode-block" id="Model.update_m_mixture"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.Model.update_m_mixture.html#particle_size_models.Model.update_m_mixture">[docs]</a>    <span class="k">def</span> <span class="nf">update_m_mixture</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m_mixture</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Update the total mass flux of the released fluids in the jet</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        m_mixture : float</span>
<span class="sd">            An array of mass fluxes (kg/s) of each pseudo-component in the</span>
<span class="sd">            live-oil mixture.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">m_mixture</span> <span class="o">=</span> <span class="n">m_mixture</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">update_properties</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">oil_mixture</span><span class="p">,</span>
                               <span class="bp">self</span><span class="o">.</span><span class="n">m_mixture</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">z0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span><span class="p">)</span></div>

<div class="viewcode-block" id="Model.simulate"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.Model.simulate.html#particle_size_models.Model.simulate">[docs]</a>    <span class="k">def</span> <span class="nf">simulate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">d0</span><span class="p">,</span> <span class="n">model_gas</span><span class="o">=</span><span class="s1">&#39;wang_etal&#39;</span><span class="p">,</span> <span class="n">pdf_gas</span><span class="o">=</span><span class="s1">&#39;lognormal&#39;</span><span class="p">,</span>
                 <span class="n">model_oil</span><span class="o">=</span><span class="s1">&#39;sintef&#39;</span><span class="p">,</span> <span class="n">pdf_oil</span><span class="o">=</span><span class="s1">&#39;rosin-rammler&#39;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Compute the parameters of the particle size distribution</span>

<span class="sd">        Computes the median bubble and droplet sizes and the spread</span>
<span class="sd">        of the selected size distributions.  Models for gas bubble median</span>
<span class="sd">        size are `wang_etal` or `li_etal`; models for oil droplet median</span>
<span class="sd">        size are `sintef` or `li_etal`.  Size distributions are either</span>
<span class="sd">        `lognormal` or `rosin-rammler`.  No matter what model is selected,</span>
<span class="sd">        the `d_95`-rule is used when the predicted size distribution would</span>
<span class="sd">        exceed the maximum stable bubble or droplet size.  Under that rule,</span>
<span class="sd">        the 95-percentile of the volume size distribution is set to the</span>
<span class="sd">        maximum stable size, and the median size is adjusted downward.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        d0 : float</span>
<span class="sd">            Equivalent circular diameter of the release orifice (m)</span>
<span class="sd">        model_gas : str, default=&#39;wang_etal&#39;</span>
<span class="sd">            Name of the model used for computing the gas bubble size</span>
<span class="sd">            distribution.  Choices are &#39;wang_etal&#39; or &#39;li_etal&#39;:.</span>
<span class="sd">        model_oil : str, default=&#39;sintef&#39;</span>
<span class="sd">            Name of the model used for computing the oil droplet size</span>
<span class="sd">            distribution.  Choices are &#39;sintef&#39; or &#39;li_etal&#39;.</span>
<span class="sd">        pdf_gas : str, default=&#39;lognormal&#39;</span>
<span class="sd">            Probability density function to use for the gas bubble size</span>
<span class="sd">            distribution.  Choices are &#39;lognormal&#39; or &#39;rosin-rammler&#39;.</span>
<span class="sd">        pdf_oil : str, default=&#39;rosin-rammler&#39;</span>
<span class="sd">            Probability density function to use for the oil droplet size</span>
<span class="sd">            distribution.  Choices are &#39;lognormal&#39; or &#39;rosin-rammler&#39;.</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        This method does not return any values.  Instead, the computed values</span>
<span class="sd">        are stored as attributes of the class object.  To report the computed</span>
<span class="sd">        values, use the `get`-methods.</span>

<span class="sd">        See Also</span>
<span class="sd">        --------</span>
<span class="sd">        get_d50, get_de_max, get_distributions</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">ModelBase</span><span class="o">.</span><span class="n">simulate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">d0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">m_gas</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">m_oil</span><span class="p">,</span>
                           <span class="n">model_gas</span><span class="o">=</span><span class="n">model_gas</span><span class="p">,</span> <span class="n">model_oil</span><span class="o">=</span><span class="n">model_oil</span><span class="p">,</span>
                           <span class="n">pdf_gas</span><span class="o">=</span><span class="n">pdf_gas</span><span class="p">,</span> <span class="n">pdf_oil</span><span class="o">=</span><span class="n">pdf_oil</span><span class="p">,</span> <span class="n">Pa</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">P</span><span class="p">,</span>
                           <span class="n">Ta</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">Tj</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="plot_phase"><a class="viewcode-back" href="../autodoc/psd/particle_size_models.plot_phase.html#particle_size_models.plot_phase">[docs]</a><span class="k">def</span> <span class="nf">plot_phase</span><span class="p">(</span><span class="n">nbins</span><span class="p">,</span> <span class="n">de</span><span class="p">,</span> <span class="n">vf</span><span class="p">,</span> <span class="n">color</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    docstring for plot_phase</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>

    <span class="c1"># Prepare data for plotting</span>
    <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">vf</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
        <span class="n">index</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">nbins</span><span class="p">)</span>
        <span class="n">bar_width</span> <span class="o">=</span> <span class="mf">0.75</span>
        <span class="n">opacity</span> <span class="o">=</span> <span class="mf">0.4</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">bar</span><span class="p">(</span><span class="n">index</span><span class="p">,</span> <span class="n">vf</span><span class="p">,</span> <span class="n">bar_width</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="n">opacity</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">color</span><span class="p">)</span>
        <span class="n">ntics</span> <span class="o">=</span> <span class="mi">10</span>
        <span class="n">ticlocs</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">nbins</span><span class="p">,</span> <span class="n">ntics</span><span class="p">)</span>
        <span class="n">ticnums</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">ntics</span><span class="o">-</span><span class="mi">1</span><span class="p">):</span>
            <span class="n">x0</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">ticlocs</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
            <span class="n">x1</span> <span class="o">=</span> <span class="n">x0</span> <span class="o">+</span> <span class="mi">1</span>
            <span class="n">y0</span> <span class="o">=</span> <span class="n">de</span><span class="p">[</span><span class="n">x0</span><span class="p">]</span>
            <span class="n">y1</span> <span class="o">=</span> <span class="n">de</span><span class="p">[</span><span class="n">x1</span><span class="p">]</span>
            <span class="n">num</span> <span class="o">=</span> <span class="p">(</span><span class="n">y1</span> <span class="o">-</span> <span class="n">y0</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="n">x1</span> <span class="o">-</span> <span class="n">x0</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">ticlocs</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">-</span> <span class="n">x0</span><span class="p">)</span> <span class="o">+</span> <span class="n">y0</span>
            <span class="n">ticnums</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%2.2f</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">num</span> <span class="o">*</span> <span class="mi">1000</span><span class="p">))</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">ticlocs</span><span class="p">,</span> <span class="n">ticnums</span><span class="p">)</span></div>

</pre></div>

          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">Texas A&M Oil spill / Outfall Calculator</a></h1>








<h3>Navigation</h3>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../user_manual.html">TAMOC User Manual</a></li>
<li class="toctree-l1"><a class="reference internal" href="../unit_tests.html">Unit Tests</a></li>
<li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../bugs.html">Reporting Bugs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../readme.html">Read Me File</a></li>
<li class="toctree-l1"><a class="reference internal" href="../release.html">Release Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../license.html">License</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="../index.html">Documentation overview</a><ul>
  <li><a href="index.html">Module code</a><ul>
  </ul></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2020, Scott A. Socolofsky.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.4</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
    </div>

    

    
  </body>
</html>